home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / blockout.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  10KB  |  315 lines

  1. /***************************************************************************
  2.  
  3. Block Out
  4.  
  5. driver by Nicola Salmoria
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11. #include "cpu/z80/z80.h"
  12.  
  13.  
  14.  
  15. extern unsigned char *blockout_videoram;
  16. extern unsigned char *blockout_frontvideoram;
  17. extern unsigned char *blockout_frontcolor;
  18.  
  19. static unsigned char *ram_blockout; /* used by high scores */
  20.  
  21. WRITE_HANDLER( blockout_videoram_w );
  22. READ_HANDLER( blockout_videoram_r );
  23. WRITE_HANDLER( blockout_frontvideoram_w );
  24. READ_HANDLER( blockout_frontvideoram_r );
  25. WRITE_HANDLER( blockout_paletteram_w );
  26. WRITE_HANDLER( blockout_frontcolor_w );
  27. int blockout_vh_start(void);
  28. void blockout_vh_stop(void);
  29. void blockout_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  30.  
  31.  
  32. int blockout_interrupt(void)
  33. {
  34.     /* interrupt 6 is vblank */
  35.     /* interrupt 5 reads coin inputs - might have to be triggered only */
  36.     /* when a coin is inserted */
  37.     return 6 - cpu_getiloops();
  38. }
  39.  
  40. READ_HANDLER( blockout_input_r )
  41. {
  42.     switch (offset)
  43.     {
  44.         case 0:
  45.             return input_port_0_r(offset);
  46.         case 2:
  47.             return input_port_1_r(offset);
  48.         case 4:
  49.             return input_port_2_r(offset);
  50.         case 6:
  51.             return input_port_3_r(offset);
  52.         case 8:
  53.             return input_port_4_r(offset);
  54.         default:
  55. logerror("PC %06x - read input port %06x\n",cpu_get_pc(),0x100000+offset);
  56.             return 0;
  57.     }
  58. }
  59.  
  60. WRITE_HANDLER( blockout_sound_command_w )
  61. {
  62.     switch (offset)
  63.     {
  64.         case 0:
  65.             soundlatch_w(offset,data);
  66.             cpu_cause_interrupt(1,Z80_NMI_INT);
  67.             break;
  68.         case 2:
  69.             /* don't know, maybe reset sound CPU */
  70.             break;
  71.     }
  72. }
  73.  
  74.  
  75. static struct MemoryReadAddress readmem[] =
  76. {
  77.     { 0x000000, 0x03ffff, MRA_ROM },
  78.     { 0x100000, 0x10000b, blockout_input_r },
  79.     { 0x180000, 0x1bffff, blockout_videoram_r },
  80.     { 0x1d4000, 0x1dffff, MRA_BANK1 },    /* work RAM */
  81.     { 0x1f4000, 0x1fffff, MRA_BANK2 },    /* work RAM */
  82.     { 0x200000, 0x207fff, blockout_frontvideoram_r },
  83.     { 0x208000, 0x21ffff, MRA_BANK3 },    /* ??? */
  84.     { 0x280200, 0x2805ff, paletteram_word_r },
  85.     { -1 }  /* end of table */
  86. };
  87.  
  88. static struct MemoryWriteAddress writemem[] =
  89. {
  90.     { 0x000000, 0x03ffff, MWA_ROM },
  91.     { 0x100014, 0x100017, blockout_sound_command_w },
  92.     { 0x180000, 0x1bffff, blockout_videoram_w, &blockout_videoram },
  93.     { 0x1d4000, 0x1dffff, MWA_BANK1, &ram_blockout },    /* work RAM */
  94.     { 0x1f4000, 0x1fffff, MWA_BANK2 },    /* work RAM */
  95.     { 0x200000, 0x207fff, blockout_frontvideoram_w, &blockout_frontvideoram },
  96.     { 0x208000, 0x21ffff, MWA_BANK3 },    /* ??? */
  97.     { 0x280002, 0x280003, blockout_frontcolor_w },
  98.     { 0x280200, 0x2805ff, blockout_paletteram_w, &paletteram },
  99.     { -1 }  /* end of table */
  100. };
  101.  
  102. static struct MemoryReadAddress sound_readmem[] =
  103. {
  104.     { 0x0000, 0x7fff, MRA_ROM },
  105.     { 0x8000, 0x87ff, MRA_RAM },
  106.     { 0x8801, 0x8801, YM2151_status_port_0_r },
  107.     { 0x9800, 0x9800, OKIM6295_status_0_r },
  108.     { 0xa000, 0xa000, soundlatch_r },
  109.     { -1 }  /* end of table */
  110. };
  111.  
  112. static struct MemoryWriteAddress sound_writemem[] =
  113. {
  114.     { 0x0000, 0x7fff, MWA_ROM },
  115.     { 0x8000, 0x87ff, MWA_RAM },
  116.     { 0x8800, 0x8800, YM2151_register_port_0_w },
  117.     { 0x8801, 0x8801, YM2151_data_port_0_w },
  118.     { 0x9800, 0x9800, OKIM6295_data_0_w },
  119.     { -1 }  /* end of table */
  120. };
  121.  
  122.  
  123. INPUT_PORTS_START( blockout )
  124.     PORT_START      /* IN0 */
  125.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  126.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
  127.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
  128.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
  129.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 )
  130.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  131.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
  132.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
  133.  
  134.     PORT_START      /* IN1 */
  135.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  136.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 )
  137.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER2 )
  138.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 )
  139.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER2 )
  140.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  141.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  142.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
  143.  
  144.     PORT_START
  145.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN1 )
  146.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 )
  147.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN3 )
  148.  
  149.     PORT_START
  150.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
  151.     PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
  152.     PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
  153.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
  154.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
  155.     /* the following two are supposed to control Coin 2, but they don't work. */
  156.     /* This happens on the original board too. */
  157.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )    /* unused? */
  158.     PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
  159.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  160.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )    /* unused? */
  161.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  162.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  163.     PORT_DIPNAME( 0x10, 0x10, "1 Coin to Continue" )
  164.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  165.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  166.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
  167.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  168.     PORT_DIPSETTING(    0x20, DEF_STR( On ) )
  169.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )    /* unused? */
  170.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  171.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  172.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )    /* unused? */
  173.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  174.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  175.  
  176.     PORT_START
  177.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
  178.     PORT_DIPSETTING(    0x02, "Easy" )
  179.     PORT_DIPSETTING(    0x03, "Normal" )
  180.     PORT_DIPSETTING(    0x01, "Hard" )
  181.     PORT_DIPSETTING(    0x00, "Very Hard" )
  182.     PORT_DIPNAME( 0x04, 0x04, "Rotate Buttons" )
  183.     PORT_DIPSETTING(    0x00, "2" )
  184.     PORT_DIPSETTING(    0x04, "3" )
  185.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  186.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  187.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  188.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
  189.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  190.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  191.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
  192.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  193.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  194.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 )
  195.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  196. INPUT_PORTS_END
  197.  
  198.  
  199.  
  200.  
  201. /* handler called by the 2151 emulator when the internal timers cause an IRQ */
  202. static void blockout_irq_handler(int irq)
  203. {
  204.     cpu_set_irq_line(1,0,irq ? ASSERT_LINE : CLEAR_LINE);
  205.     /* cpu_cause_interrupt(1,0xff); */
  206. }
  207.  
  208. static struct YM2151interface ym2151_interface =
  209. {
  210.     1,            /* 1 chip */
  211.     3579545,    /* 3.579545 Mhz (?) */
  212.     { YM3012_VOL(60,MIXER_PAN_LEFT,60,MIXER_PAN_RIGHT) },
  213.     { blockout_irq_handler }
  214. };
  215.  
  216. static struct OKIM6295interface okim6295_interface =
  217. {
  218.     1,                  /* 1 chip */
  219.     { 8000 },           /* 8000Hz frequency */
  220.     { REGION_SOUND1 },              /* memory region 3 */
  221.     { 50 }
  222. };
  223.  
  224.  
  225.  
  226. static struct MachineDriver machine_driver_blockout =
  227. {
  228.     /* basic machine hardware */
  229.     {
  230.         {
  231.             CPU_M68000,
  232.             8760000,       /* MRH - 8.76 makes gfx/adpcm samples sync better */
  233.             readmem,writemem,0,0,
  234.             blockout_interrupt,2
  235.         },
  236.         {
  237.             CPU_Z80 | CPU_AUDIO_CPU,
  238.             3579545,    /* 3.579545 Mhz (?) */
  239.             sound_readmem,sound_writemem,0,0,
  240.             ignore_interrupt,1    /* NMIs are triggered by the main CPU, IRQs by the YM2151 */
  241.         }
  242.     },
  243.     60, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  244.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  245.     0,
  246.  
  247.     /* video hardware */
  248.     320, 256, { 0, 319, 8, 247 },
  249.     0,
  250.     513, 0,
  251.     0,
  252.  
  253.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  254.     0,
  255.     blockout_vh_start,
  256.     blockout_vh_stop,
  257.     blockout_vh_screenrefresh,
  258.  
  259.     /* sound hardware */
  260.     SOUND_SUPPORTS_STEREO,0,0,0,
  261.     {
  262.         {
  263.             SOUND_YM2151,
  264.             &ym2151_interface
  265.         },
  266.         {
  267.             SOUND_OKIM6295,
  268.             &okim6295_interface
  269.         }
  270.     }
  271. };
  272.  
  273.  
  274.  
  275. /***************************************************************************
  276.  
  277.   Game driver(s)
  278.  
  279. ***************************************************************************/
  280.  
  281. ROM_START( blockout )
  282.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 2*128k for 68000 code */
  283.     ROM_LOAD_EVEN( "bo29a0-2.bin", 0x00000, 0x20000, 0xb0103427 )
  284.     ROM_LOAD_ODD ( "bo29a1-2.bin", 0x00000, 0x20000, 0x5984d5a2 )
  285.  
  286.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for the audio CPU */
  287.     ROM_LOAD( "bo29e3-0.bin", 0x0000, 0x8000, 0x3ea01f78 )
  288.  
  289.     ROM_REGION( 0x20000, REGION_SOUND1 )    /* 128k for ADPCM samples - sound chip is OKIM6295 */
  290.     ROM_LOAD( "bo29e2-0.bin", 0x0000, 0x20000, 0x15c5a99d )
  291.  
  292.     ROM_REGION( 0x0100, REGION_PROMS )
  293.     ROM_LOAD( "mb7114h.25",   0x0000, 0x0100, 0xb25bbda7 )    /* unknown */
  294. ROM_END
  295.  
  296. ROM_START( blckout2 )
  297.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 2*128k for 68000 code */
  298.     ROM_LOAD_EVEN( "29a0",         0x00000, 0x20000, 0x605f931e )
  299.     ROM_LOAD_ODD ( "29a1",         0x00000, 0x20000, 0x38f07000 )
  300.  
  301.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for the audio CPU */
  302.     ROM_LOAD( "bo29e3-0.bin", 0x0000, 0x8000, 0x3ea01f78 )
  303.  
  304.     ROM_REGION( 0x20000, REGION_SOUND1 )    /* 128k for ADPCM samples - sound chip is OKIM6295 */
  305.     ROM_LOAD( "bo29e2-0.bin", 0x0000, 0x20000, 0x15c5a99d )
  306.  
  307.     ROM_REGION( 0x0100, REGION_PROMS )
  308.     ROM_LOAD( "mb7114h.25",   0x0000, 0x0100, 0xb25bbda7 )    /* unknown */
  309. ROM_END
  310.  
  311.  
  312.  
  313. GAME( 1989, blockout, 0,        blockout, blockout, 0, ROT0, "Technos + California Dreams", "Block Out (set 1)" )
  314. GAME( 1989, blckout2, blockout, blockout, blockout, 0, ROT0, "Technos + California Dreams", "Block Out (set 2)" )
  315.